package cn.itcast.web.controller.system;

import cn.itcast.domain.system.SysLog;
import cn.itcast.service.system.SysLogService;
import cn.itcast.web.controller.BaseController;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author LT
 * @version 1.0.0
 * @ClassName SysLogController.java
 * @Description TODO
 * @createTime 2020年03月26日 19:28:00
 */
@Controller
@RequestMapping("/system/log")
public class SysLogController extends BaseController {

    @Autowired
    private SysLogService sysLogService;

    /**
     * 方法的作用：展示日志列表
     *     url: /system/log/list.do
     *     参数： 当前页， 页面大小
     *     返回： system/log/log-list
     * @param pageNum
     * @param pageSize
     * @return
     */
    @RequestMapping("list")
    public String list(@RequestParam(defaultValue = "1") int pageNum,
                       @RequestParam(defaultValue = "10") int pageSize) {
        //1. 查询到pageInfo对象
        //companyId是指当前登陆者所属的公司id.
        String companyId = getLoginCompanyId();
        PageInfo<SysLog> pageInfo = sysLogService.findByPage(pageNum, pageSize, companyId);

        // 2.把PageInfo存储到域中
        request.setAttribute("pageInfo", pageInfo);
        return "system/log/log-list";
    }
}
